package cn.wetcland.es.controller;

import cn.wetcland.es.dto.StudentDeleteDTO;
import cn.wetcland.es.dto.StudentUpdateDTO;
import cn.wetcland.es.service.EsStudentService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;

@Controller
@RequestMapping("/manageStudent")
public class StudentController {

    @Resource
    private EsStudentService studentService;

    @RequestMapping("/updateStudent")
    public String updateStudent(StudentUpdateDTO studentUpdateDTO) {
        studentService.updateStudent(studentUpdateDTO);
        return "redirect:/manageStudent?classId=" + studentUpdateDTO.getClassId();
    }

    @RequestMapping("/deleteStudent")
    public String deleteStudent(StudentDeleteDTO studentDeleteDTO) {
        studentService.deleteStudent(studentDeleteDTO);
        return "redirect:/manageStudent?classId=" + studentDeleteDTO.getClassId();
    }

}
